<?php

class Osml_View_Helper_Generationmenu extends Zend_View_Helper_Abstract
{
    public function generationmenu($tableau) {
        
        $request = Zend_Controller_Front::getInstance()->getRequest();
        
        $html = "<ul>";
            foreach ( $tableau as $competition) {
                $class = ($request->getModuleName() == "front" && $request->getControllerName() == "competitions" ? "selected" : "");
                $html .= "<li class='$class'><a href='" . ($competition->getUrl() != "" ? $competition->getUrl() : "#") . "'>{$competition->getNom()}</a>";
                $tmpCompetitions = Back_Model_Competitions::competitionsParNiveau($competition->getId());
                if (!empty($tmpCompetitions)) {
                    $html .= $this->generationmenu($tmpCompetitions);
                } 
                $html .= "</li>";
            }
        $html .= "</ul>";
        
        return $html;
    }
}
